package com.example.demo.controller;


import com.example.demo.dto.ResultJson;
import com.example.demo.entity.Cangku;
import com.example.demo.entity.Chukujilu;
import com.example.demo.entity.Rukujilu;
import com.example.demo.mapper.Cangku_Mapper;
import com.example.demo.mapper.Chukujilu_Mapper;
import com.example.demo.mapper.Danweixinxi_Mapper;
import com.example.demo.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("Chukujilu")
public class Chukujilu_Controller extends BasicController<Chukujilu> {
	@Autowired
	Chukujilu_Mapper mapper;
	@Autowired
	Cangku_Mapper cangku_mapper;
	@Autowired
	Danweixinxi_Mapper danweixinxi_mapper;

	@Override
	public ResultJson insert(Chukujilu c) {

		int shuliang = c.getCaozuoshuliang();
		int id = c.getShangpinid();
		cangku_mapper.jianshaoshuliang(id,shuliang);
		c.setChukutime(DateUtils.getNowTime());

		danweixinxi_mapper.addone1();

		return super.insert(c);
	}
	@RequestMapping("/update")
	public ResultJson update(Chukujilu c){
		c.setChukutime(DateUtils.getNowTime());
		super.update(c);
		return new ResultJson(1);
	}

}
